<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>书架</title>
    <meta name="keywords" content="我的书架,临时书架,浏览记录,书趣阁_笔趣阁"/>
    <meta name="description" content="书趣阁_笔趣阁是广大书友最值得收藏的阅读网，我的书架 - 临时书架 - 浏览记录，书趣阁_笔趣阁是广大爱好者必备的小说阅读网。"/>
    <link href="../css/user/shelf.css" rel="stylesheet" type="text/css"/>

    <script src="/js/common.js"></script>
    <script src="/js/pc_pf.js"></script>
    <script src="/js/bookcase.js"></script>

    <script type="text/javascript" src="../js/jquery-3.2.1/jquery-3.2.1.min.js"></script>
    <link rel="stylesheet" href="../css/user/details.css">
    <link rel="stylesheet" type="text/css" href="../css/user/conmont.css">
    <!--    <script type="text/javascript" src="../js/checkUser.js"></script>-->
</head>

<script>
    $(function () {
        // 引入header
        $(".headerpage").load("header.html");
        // 引入footer
        $(".footerpage").load("footer.html");
    });
</script>

<body>
<div id="wrapper">

    <div class="headerpage"></div>

    <div class="box_con">
        <div class="aaa"></div>
    </div>

    <div class="clear"></div>

    <div class="wrap">
        <div class="bookcase">
            <h2>我的书架</h2>
            <div class="read_book"></div>
            <div class="bookbox r10">
                <div class="p10"><span class="num">1</span>
                    <div class="bookinfo"><h4 class="bookname"><a href="/txt/5809/index.html">元尊</a></h4>
                        <div class="cat">分类：玄幻魔法</div>
                        <div class="author">作者：天蚕土豆</div>
                        <div class="update"><span>最新：</span><a href="/txt/5809/36087383.html">完本感言</a></div>
                    </div>
                    <div class="delbutton"><a class="del_but"
                                              href="javascript:if(confirm('确实要将本书移出书架么？')) document.location='/delbookcase/5809.php';">删除</a>
                    </div>
                    <div class="readbutton"><a class="del_but"
                                               href="javascript:if(confirm('确实要将本书移出书架么？')) document.location='/delbookcase/5809.php';">继续阅读</a>
                    </div>
                </div>
            </div>

            <div class="bookbox">
                <div class="p10"><span class="num">2</span>
                    <div class="bookinfo"><h4 class="bookname"><a href="/txt/63542/index.html">三寸人间</a></h4>
                        <div class="cat">分类：武侠修真</div>
                        <div class="author">作者：耳根</div>
                        <div class="update"><span>最新：</span><a href="/txt/63542/41644817.html">12年创作生涯的完本总结与感言</a></div>
                    </div>
                    <div class="delbutton"><a class="del_but"
                                              href="javascript:if(confirm('确实要将本书移出书架么？')) document.location='/delbookcase/63542.php';">删除</a>
                    </div>
                    <div class="readbutton"><a class="del_but"
                                               href="javascript:if(confirm('确实要将本书移出书架么？')) document.location='/delbookcase/5809.php';">继续阅读</a>
                    </div>
                </div>
            </div>


        </div>
    </div>

    <div style="height: 400px;"></div>

    <div id="footer" name="footer" class="footerpage"></div>
</div>
</body>
</html>

<script>

    $(function () {
        // .search是获取地址栏中地址之后的所有书籍
        var url = window.location.search.split('?');
        // 获取到的参数是被转译过的，需要转译回来
        var bId = decodeURIComponent(url[1])
        console.log(bId)

        $.ajax({
            url: "http://127.0.0.1:8001/front/frDetail"
            , type: "get"
            , data: { "bId": bId }
            , success: function (datas) {
                var types = datas.data.types
                var book = datas.data.book
                var chapters = datas.data.chapters

                // 分类列表模块
                console.log(types)
                for (var type of types) {
                    var ty = '';
                    ty += `<li><a href="./type.html?` + type.cate + `">` + type.cate + `</a></li>`
                    $('.top-nav-wrap .left-nav ul').append(ty)
                }

                // 书籍详情模块
                console.log(book)
                for (var bo of book) {
                    var time = bo.updateTime.substring(0,20)
                    var b = '';
                    b += `<div class="con_top">
                    <div id="bdshare" class="bdshare_b" style="line-height: 12px;"></div>
                    <a href="./index.html">云阅读</a> &gt; `+ bo.cate +` &gt; `+ bo.bTitle +`
                  </div>
                  <div id="maininfo">
                    <div id="info">
                      <h1>`+ bo.bTitle +`</h1>
                      <p>作&nbsp;&nbsp;&nbsp;&nbsp;者：`+ bo.author +`</p>
                      <p>最后更新：2020-12-02 14:03:40</p>
                    </div>
                    <div id="intro">
                        <p>`+ bo.introduce +`</p>
                    </div>
                  </div>
                  <div id="sidebar">
                    <div id="fmimg"><img src=`+ bo.bPicture +` width="152" height="195" /></div>
                  </div>`
                    $('#wrapper .box_con .aaa').append(b)
                }

                // 章节模块
                console.log(chapters)
                var chap = chapters[chapters.length-1]
                if(chap == null ){
                    alert('该书还未添加章节,两秒后自动跳回首页')
                    setTimeout(function(){
                        location.href = './index.html'
                    } ,2000);
                    return false;
                }
                // 转译章节题目 后才能传多个数据 ,否则只能传三个汉字
                var ti = encodeURIComponent(chap.cTitle)
                var cc = '';
                cc +=`<dt><b>《`+ book[0].bTitle +`》最新章节</b></dt>
                <dd><a href=./reading.html?`+ ti +`?`+ chap.bId +` >`+ chap.cTitle +`</a></dd>
                <dt>《`+ book[0].bTitle +`》正文</dt>`
                $('#list dl').append(cc);
                for (var chapter of chapters) {
                    // 转译章节题目 后才能传多个数据 ,否则只能传三个汉字
                    var tit = encodeURIComponent(chapter.cTitle)
                    var ch = '';
                    ch += `<dd><a href=./reading.html?`+ tit +`?`+ chapter.bId +` >`+ chapter.cTitle +`</a></dd>`
                    $('#list dl').append(ch)
                }

            }
            , error: function () {
                alert("连接超时，请刷新页面！！！")
            }
        });
    })

</script>

